// 基于template/src/widgets/{{appEntities}}/{{ctrls@GRID}}-grid/{{spinalCase ctrl.codeName}}-grid-model.ts.hbs生成
import { IGridModel, IParam, isEmpty, VerifyUtil } from '@/core';

function getModel(): IGridModel {
	return {
		cssName: '',
		aggMode: 'NONE',
		caption: '',
		controlType: 'GRID',
		codeName: 'Main',
		columns: getGridColumns(),
		dataItems: getGridDataItems(),
		dataExport: getDataExport(),
		enableRowEdit: false,
		entityCodeName: 'AUTH_LOG',
		entityLogicName: '登录日志',
		createDefaultItems: getCreateDefaultItems(),
		updateDefaultItems: getUpdateDefaultItems(),
		name: 'grid',
		noSort: false,
		rules: {
			//	静态值规则
			staticRules: {},
			//	编辑项值规则
			editRules: [],
		},
		showHeader: true,
		sortDir: 'DESC',
		sortField: 'timestmp',
		limit: 20,
		paging: {
			defaultPageSize: 20,
		},
		uiEngineModel: [
			{
				name: 'engine_grid',
				triggerType: 'CTRLEVENT',
				logicType: 'APPVIEWENGINE',
				eventNames: 'ROWDBLCLICK;SELECTIONCHANGE;REMOVE;LOAD;BEFORELOAD',
				scriptCode: ``,
				entityCodeName: '',
				logicName: ``,
			},
		],
	};
}
//  获取所有表格列模型
function getGridColumns(): IParam[] {
	return [
		{
			align: 'left',
			codeName: 'arg0',
			caption: '登录名称',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'arg0',
			dataIndex: 'arg0',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '登录名称',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'arg0',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'arg1',
			caption: '中文名',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'arg1',
			dataIndex: 'arg1',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '中文名',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'arg1',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'thread_name',
			caption: '登录地址',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'thread_name',
			dataIndex: 'thread_name',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '登录地址',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'thread_name',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'reference_flag',
			caption: '登录状态',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			codeListTag: 'authentication__Auth_log_status',
			dataItemName: 'reference_flag',
			dataIndex: 'reference_flag',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '登录状态',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'reference_flag',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 9,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'arg2',
			caption: '操作信息',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'arg2',
			dataIndex: 'arg2',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '操作信息',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'arg2',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'time',
			caption: '登录时间',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'time',
			dataIndex: 'time',
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: false,
			excelCaption: '登录时间',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'time',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 5,
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
		},
	];
}

//  获取所有表格数据项
function getGridDataItems() {
	return [
		{
			name: 'arg0',
			codeName: '',
			customCode: false,
			fieldCodeName: 'arg0',
			fieldName: 'arg0',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'arg1',
			codeName: '',
			customCode: false,
			fieldCodeName: 'arg1',
			fieldName: 'arg1',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'thread_name',
			codeName: '',
			customCode: false,
			fieldCodeName: 'ip_address',
			fieldName: 'thread_name',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'reference_flag',
			codeName: '',
			customCode: false,
			fieldCodeName: 'status',
			fieldName: 'reference_flag',
			valueFormat: '',
			dataType: '9',
		},
		{
			name: 'arg2',
			codeName: '',
			customCode: false,
			fieldCodeName: 'arg2',
			fieldName: 'arg2',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'time',
			codeName: '',
			customCode: false,
			fieldCodeName: 'time',
			fieldName: 'time',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			dataType: '5',
		},
		{
			name: 'srfkey',
			codeName: '',
			customCode: false,
			fieldCodeName: 'id',
			fieldName: 'event_id',
			valueFormat: '',
			dataType: '1',
		},
		{
			name: 'srfdataaccaction',
			codeName: '',
			customCode: false,
			fieldCodeName: 'id',
			fieldName: 'event_id',
			valueFormat: '',
			dataType: '1',
		},
		{
			name: 'srfmajortext',
			codeName: '',
			customCode: false,
			fieldCodeName: 'name',
			fieldName: 'logger_name',
			valueFormat: '',
			dataType: '25',
		},
	];
}

function getDataExport() {
	return {
		default: true,
		codeName: 'default',
		enableFront: true,
		fileName: '登录日志',
		exportItems: [
			{
				name: 'arg0',
				label: '登录名称',
				labelLanResTag: '',
				dataType: 25,
				show: true,
			},
			{
				name: 'arg1',
				label: '中文名',
				labelLanResTag: '',
				dataType: 25,
				show: true,
			},
			{
				name: 'thread_name',
				label: '登录地址',
				labelLanResTag: '',
				dataType: 25,
				show: true,
			},
			{
				name: 'reference_flag',
				label: '登录状态',
				labelLanResTag: '',
				dataType: 9,
				codeListTag: 'authentication__Auth_log_status',
				show: true,
			},
			{
				name: 'arg2',
				label: '操作信息',
				labelLanResTag: '',
				dataType: 25,
				show: true,
			},
			{
				name: 'time',
				label: '登录时间',
				labelLanResTag: '',
				dataType: 5,
				valueFormat: 'YYYY-MM-DD HH:mm:ss',
				show: true,
			},
		],
	};
}

function getCreateDefaultItems() {
	return [];
}

function getUpdateDefaultItems() {
	return [];
}

export const model = getModel();
